#include <cpptoml.h>
#include <string>
#include <iostream>

struct Config {
    std::string zmq_remote_host;
    size_t zmq_producer_port;
    size_t zmq_collector_rs_port;
    size_t zmq_collector_ws_port;
    size_t zmq_db_port;
    std::string redis_host;
    size_t redis_port;
    std::string redis_password;
    int redis_subs_db;
    int redis_stat_db;
    int redis_node_db;
    int redis_param_db;
    size_t server_buffer_max;

    explicit Config(const std::string &file) {
        auto config = cpptoml::parse_file(file);
        zmq_remote_host = config->get_qualified_as<std::string>("zmq.remote_host").value_or("");
        zmq_producer_port = config->get_qualified_as<size_t>("zmq.producer_port").value_or(0);
        zmq_collector_rs_port = config->get_qualified_as<size_t>("zmq.collector_rs_port").value_or(0);
        zmq_collector_ws_port = config->get_qualified_as<size_t>("zmq.collector_ws_port").value_or(0);
        zmq_db_port = config->get_qualified_as<size_t>("zmq.db_port").value_or(0);
        redis_host = config->get_qualified_as<std::string>("redis.host").value_or("");
        redis_port = config->get_qualified_as<size_t>("redis.port").value_or(0);
        redis_password = config->get_qualified_as<std::string>("redis.password").value_or("");
        redis_subs_db = config->get_qualified_as<int>("redis.subs_db").value_or(0);
        redis_stat_db = config->get_qualified_as<int>("redis.stat_db").value_or(0);
        redis_node_db = config->get_qualified_as<int>("redis.node_db").value_or(0);
        redis_param_db = config->get_qualified_as<int>("redis.param_db").value_or(0);
        server_buffer_max = config->get_qualified_as<size_t>("server.buffer_max").value_or(100);
    }
};

int main() {
    auto config = Config("../../sample_1/config.conf.sample");
    std::cout << config.zmq_remote_host << ":" << config.zmq_producer_port << std::endl;
}